<template>
	<view class="content">
		<u-sticky bgColor="#fff">
			<u-tabs lineColor='#00b6b2' :list="tablist" @click="click"></u-tabs>
		</u-sticky>
		<view class="color-line wdh-100" style="height: 2rpx;"></view>
		<view v-for="(item,index) in list" :key='index' class="columnbox one-info color-line"
			@click="showDetail(item.id)">
			<view class="u-box rowbox wdh-100 spb">
				<view>{{item.name}} {{item.sex=='2'?'女':'男'}} {{item.age}}岁
				</view>
				<u-icon name="arrow-right" size="28rpx"></u-icon>
			</view>
			<view class="wdh-100 zhenduan">【诊断】{{item.bianbing}}</view>
			<view class="wdh-100 rowbox spb info-desc">
				<view>{{toLocalDate(item.addtime)}}</view>
				<view style="color: #fc4217;">{{getPayStatus(item.paystatus)}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import getDate from '@/utils/time.js'
	export default {
		data() {
			return {
				tablist: [{
						name: '全部'
					},
					{
						name: '未支付'
					},
					{
						name: '已支付'
					},
					{
						name: '已撤回'
					}
				],
				current: 0,
				pageNo: 1,
				list: [],
				total: 0
			};
		},
		onLoad() {
			this.getInfo()
		},
		onReachBottom() {
			if (this.list.length < this.total) {
				this.pageNo++
				this.getInfo()
			}
		},
		methods: {
			showDetail(id) {
				uni.navigateTo({
					url: '/packageA/chatInfo/zhongyao?id=' + id
				})
			},
			toLocalDate(v) {
				return getDate.toLocalDate(v)
			},
			click(e) {
				this.current = e.index
				this.pageNo = 1
				this.list = []
				this.getInfo()
			},
			getInfo() {
				this.$req.post('/doctor/prescriptionlist', {
					doctorid: uni.getStorageSync('uid'),
					paystatus: this.current == 3 ? -1 : this.current,
					pageNo: this.pageNo,
					pageSize: 20
				}).then(res => {
					this.list = this.list.concat(res.data.data.data)
					this.total = res.data.data.totalCount
				})
			},
			getPayStatus(v) {
				switch (v) {
					case 1:
						return '未支付'
						break;
					case 2:
						return '已支付'
						break;
					case 3:
						return '待收货'
						break;
					case 4:
						return '已收货'
						break;
					default:
						return '已撤回'
						break;
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		font-family: PingFang SC-Regular, PingFang SC;
	}

	.one-info {
		width: 100%;
		padding: 20rpx 20rpx;
		font-size: 28rpx;
	}

	.color-line {
		border-bottom: #f3f3f3 solid 20rpx;
	}

	.u-box {
		border-bottom: #f3f3f3 solid 1px;
		padding-bottom: 20rpx;
		font-weight: bold;
	}

	.zhenduan {
		margin-top: 20rpx;
		font-size: 24rpx;
	}

	.info-desc {
		margin-top: 20rpx;
		font-size: 24rpx;
		color: #707071;
	}
</style>